--Files that need to be sent to client from server:
AddCSLuaFile("MckaysPack.lua");

MckaysPack = MckaysPack or {};
MckaysPack.Ents = MckaysPack.Ents or {}; --At the moment, used for Debug, to see if All the right Ents ARE installed and working
MckaysPack.ColorList = MckaysPack.ColorList or {};
MckaysPack.Settings = MckaysPack.Settings or {};

--[[*******************************************************************************************************************************************
*****************************************************     DO NOT EDIT ANYTHING ABOVE THIS LINE!!!**********************************************
*******************************************************************************************************************************************]]--

--How about we list config variables below this line. Then other people can change them dynamically in game.
--MckaysPack.Ents.[entname].[key] = [value]  Entname MUST match CreateEnt name + correct formatting!!!
function MckaysPack:SetupConfig(name)
	if(name == "ZeroPointModuleMK2") then
		--table.insert(MckaysPack.AdminCheck,name); 				--Enable this to make Admin ONLY!
		--MckaysPack.Ents.ZeroPointModuleMK2.MaxEnergy = 10000000000;		--Original ZPM size: 10000000
		--MckaysPack.Ents.ZeroPointModuleMK2.MaxStorage = 50000000;		--Original ZPM Storage: 5000
		--MckaysPack.Ents.ZeroPointModuleMK2.ExplosionRadius = 6;
		--MckaysPack.Ents.ZeroPointModuleMK2.Max = 2;					-- This effects ALL players INCLUDING Admins and SuperAdmins!!
		MckaysPack.Ents.ZeroPointModuleMK2.Count = 0;				--DONT change this one!!!
	end
	if(name == "ZPMSpawner") then
		--MckaysPack.Ents.ZPMSpawner.ZPMMax = 6;
		--table.insert(MckaysPack.AdminCheck,name); 				--Enable this to make Admin ONLY!
	end
	if(name == "Touchstone") then
		--MckaysPack.Ents.Touchstone.Max = 1;
		--table.insert(MckaysPack.AdminCheck,name); 				--Enable this to make Admin ONLY!
	end
	if(name == "NaquadahBottle") then
		--MckaysPack.Ents.NaquadahBottle.NaqBottleMax = 4				--The max number of Naquadha bottles to spawn
		--MckaysPack.Ents.NaquadahBottle.MaxEnergy = 30000			--This is the max ammount of energy in the Naquadha bottle
		--MckaysPack.Ents.NaquadahBottle.MaxStorage = 800				--Atm i really dont know what this is :P
		--table.insert(MckaysPack.AdminCheck,name); 				--Enable this to make Admin ONLY!
	end
	if(name == "AncientGun") then
		MckaysPack.Ents.AncientGun.Color = MckaysPack.ColorList.ORANGE;			--This changes the colour of the Ancient Gun ... funny that o.O
		--MckaysPack.Ents.AncientGun.Round = 16;									--Values avilable are below
		--MckaysPack.Ents.AncientGun.ChargeTime = 8;								--This is how long it takes to charge
		--MckaysPack.Ents.AncientGun.Model = 2;									--1: Ancient Gun, 2:Asuran Stunner
	end
	if(name == "EMPGen") then
		--MckaysPack.Ents.EMPGen.countdown = 10;						--Time until emp charge activates
		--MckaysPack.Ents.EMPGen.cooldowntime = 60;					--Dah, the cooltime time!
		--MckaysPack.Ents.EMPGen.duration = 30;						--This MUST be below the cooldown time. (good value is about half of the cooldown time.)
	end
end

--[[*******************************************************************************************************************************************
*****************************************************     DO NOT EDIT ANYTHING BELOW THIS LINE!!!**********************************************
*******************************************************************************************************************************************]]--

function math.AdvRound( val, d ) --round val to number of decimal points d.
	d = d or 0;
	return math.Round( val * (10 ^ d) ) / (10 ^ d);
end 

local function GetVersion()  --By Salads FP forums -- modified by Meeces2911 for MckaysPack
	for k, v in pairs(file.FindDir("../addons/*")) do 
		local File = "../addons/" .. v .. "/info.txt"  
        if ( file.Exists(File) ) then  
            local AddonData = util.KeyValuesToTable(file.Read(File))
			if(AddonData["name"] == "Stargate Mod Pack") then
				return math.AdvRound(AddonData["version"],1) or 0 --in theory round to 1dp
			end
		end  
	end  
end  

function MckaysPack:CreateEnt(value)
	local newvalue = string.Implode("",string.Explode("-",string.Implode("", string.Explode(" ", value))))  --Should make a new function with all the remove formatting in it
	MckaysPack.Ents [newvalue] = {}
	MckaysPack:SetupConfig(newvalue)
end

MckaysPack.Version = GetVersion() or 0
MsgN("===================================================")
MsgN("Mckays Stargate Pack Addon Installed Version: "..MckaysPack.Version)
MsgN("===================================================")

if CLIENT then
	surface.CreateFont( "arial", 80, 600, true, false, "ZpmTitle" )	--Own Font (Like the RD3 font, but slightly bigger)
	surface.CreateFont( "arial", 60, 600, true, false, "ZpmText" )	--Own Font (Like the RD3 font, but slightly bigger)
end

--################### Colors @ Avon, Mckay, Meeces
--This helps the config and people to change colors of the energy bursts.
MckaysPack.ColorList.RED = 			Angle(255,0,0); -- Angle(p, y, r);
MckaysPack.ColorList.GREEN = 		Angle(0,255,0);
MckaysPack.ColorList.BLUE = 		Angle(0,0,255);
MckaysPack.ColorList.WHITE = 		Angle(255,255,255);
MckaysPack.ColorList.ORANGE = 		Angle(255,127,0);
MckaysPack.ColorList.YELLOW = 		Angle(255,255,0);
MckaysPack.ColorList.PURPLE = 		Angle(128,0,128);
MckaysPack.ColorList.ORIGINAL = 	Angle(50,255,50);
MckaysPack.ColorList.MCKAYSC = 		Angle(42,82,190);
MckaysPack.ColorList.ANCIENT = 		Angle(119,176,255);
MckaysPack.ColorList.INDIGO = 		Angle(0,65,106);